import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;

public class TwoServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 1. 通过请求对象获得{请求头}中所有{请求参数名}
        // request.getParameterNames(), 将所有参数名统一保存进一个枚举对象中
        Enumeration paramNames = request.getParameterNames();
        while (paramNames.hasMoreElements()) {
            String paramName = (String)paramNames.nextElement();
            // 2. 通过请求参数名获取请求参数值
            // request.getParameter(paramName), 参数为请求参数名, 返回它对应的值, 是String类型
            String value = request.getParameter(paramName);
            System.out.println(paramName + "=" + value);
        }
    }
}
